package com.example.sample.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

@Component
public class RedisSample {
    @Autowired
    private StringRedisTemplate redisTemplate;

    public void testSet() {
        int keyId = ThreadLocalRandom.current().nextInt(1000) + 1;
        String uuid = UUID.randomUUID().toString();
        redisTemplate.opsForValue().set("test_key", uuid + "_" + keyId);
        System.out.println(redisTemplate.opsForValue().get("test_key"));
    }

}
